import time

from selenium.webdriver.common.by import By

from base.mis.base_page import BasePage, BaseOperate
from utils import UtilsDriver


class HomePage(BasePage):
    def __init__(self):
        super().__init__()
        self.user_info = By.CSS_SELECTOR, ".user_info span"
        self.info_manger = By.XPATH, "//*[@class='side_bar']/ul/li[3]/a"
        self.content_inspect = By.XPATH, "//*[@class='side_bar']/ul/li[3]/ul/li[3]"

    def find_user_info(self):
        return self.get_element(self.user_info)

    def find_info_manger(self):
        return self.get_element(self.info_manger)

    def find_content_inspect(self):
        return self.get_element(self.content_inspect)


class HomeOperate(BaseOperate):
    def __init__(self):
        self.hp = HomePage()

    def return_user_info(self):
        return self.hp.find_user_info().text

    def click_info_manger(self):
        self.hp.find_info_manger().click()

    def click_content_inspect(self):
        self.hp.find_content_inspect().click()


class HomeBusiness:
    def __init__(self):
        self.ho = HomeOperate()

    def get_user_info(self):
        return self.ho.return_user_info()

    def go_content_inspect_page(self):
        self.ho.click_info_manger()
        time.sleep(2)
        self.ho.click_content_inspect()
